{extend name="base" /}
{block name="body"}
<div class="layui-card">
    <div class="layui-card-body">
        <form action="{:request()->url()}" class="layui-form" method="post">
            <div class="layui-form-item">
                <label class="layui-form-label">文章标题</label>
                <div class="layui-input-block">
                    <input type="text" name="title" value="{$data.title|default=''}" autocomplete="off" placeholder="" lay-verify="required" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">所属分类</label>
                <div class="layui-input-inline">
                    <select name="cid" lay-search>
                        <option value="">请选择分类</option>
                        {foreach name="category" item="v"}
                        <option value="{$v.id}" {if condition="isset($data) and $data.cid eq $v.id"}selected="selected"{/if}>{neq name="v.level" value="1"}|{php}for($i=1;$i<$v['level'];$i++){echo ' ----';}{/php}{/neq} {$v.name}</option>
                        {/foreach}
                    </select>
                </div>
                <label class="layui-form-label">作者</label>
                <div class="layui-input-inline">
                    <input type="text" name="author" value="{$data.author|default=''}" autocomplete="off" placeholder="作者" class="layui-input">
                </div>
                <label class="layui-form-label">来源</label>
                <div class="layui-input-inline">
                    <input type="text" name="source" value="{$data.source|default=''}" autocomplete="off" placeholder="来源" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">封面图片</label>
                <div class="layui-input-block">
                    {:get_field('image',isset($data.image)?$data.image:'','image','image')}
                </div>
            </div>
            <div class="layui-form-item" style="margin-bottom: 14px;">
                <label class="layui-form-label">文章标签</label>
                <div class="layui-input-block">
                    <input id="demoTagsInput3" name="keywords" value="{$data.keywords|default=''}"  class="layui-hide"/>
                </div>
            </div>
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">META描述</label>
                <div class="layui-input-block">
                    <textarea name="description" class="layui-textarea">{$data.description|default=''}</textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">详细内容</label>
                <div class="layui-input-block">
                    <textarea id="demoEditor" name="content">{$data.content|default=''}</textarea>
                </div>
            </div>
            
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-filter="*" lay-submit="">保存</button>
                    <button class="layui-btn layui-btn-primary" type="reset">重置</button>
                </div>
            </div>
        </form>
    </div>
</div>
{/block}
{block name="js"}
<!--编辑器-->
<script type="text/javascript" src="/static/hqui/libs/tinymce/tinymce.min.js"></script>
<script type="text/javascript" src="/static/hqui/js/tinymce.js"></script>
<script>
    layui.use(['jquery', 'tagsInput'], function () {
        var $ = layui.jquery;
        var tagsInput = layui.tagsInput;
        // BackSpace键可删除标签
        $('#demoTagsInput3').tagsInput({removeWithBackspace: true});
    });
</script>
{/block}